home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 12638 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.1 KB  |  50 lines

  1. Path: colossus.holonet.net!russell
  2. From: russell@news.mdli.com (Russell Blackadar)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Help! Newbie question ...
  5. Date: 19 Mar 1996 22:52:03 GMT
  6. Organization: HoloNet National Internet Access System: 510-704-1058/modem
  7. Message-ID: <4indqj$eqo@colossus.holonet.net>
  8. References: <4ilkfu$41q@Kaos.deepcove.com> <4imrip$8gi@firebrick.mindspring.com>
  9. NNTP-Posting-Host: jubal.mdli.com
  10. X-Newsreader: TIN [version 1.2 PL2]
  11.  
  12. Justin Rudd (rudd@mindspring.com) wrote:
  13. > saffleck@deepcove.com (Sean Affleck) wrote:
  14.  
  15. > >Is this legal ? 
  16.  
  17. > >class A {...};
  18.  
  19. > >A f();
  20.  
  21. > >main() {
  22. > >  A a = f();
  23. > >}
  24.  
  25. > >A f()
  26. > >{
  27. > >   A fa;
  28. > >   return fa;
  29. > >}
  30.  
  31. > Sure is....just make sure you have a copy constructor and an
  32. > assignment operator.
  33.  
  34. Well, I hope you don't think the assignment operator is
  35. invoked for an initialization.  It isn't.
  36.  
  37. A statement like
  38.  
  39.     A a = something;
  40.  
  41. means exactly the same thing as
  42.  
  43.     A a(something);
  44.  
  45. and in both cases, the appropriate ctor is invoked to do
  46. the initialization.  The statement A a = f(); invokes the
  47. copy ctor.
  48. --
  49. Russell Blackadar,   russell@mdli.com
  50.